m, n = map(int, input().smit(' '))
a = list(map(int, input().smit(' ')))
s = [0]*(len(a) + 1)
for i in range(m):
    s[i+1] = a[i]+s[i]
while n > 0:
    a, b = map(int, input().smit(' '))
    print(s[b]-s[a-1])
    n -= 1
